package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.BuyOrderBean;
import com.project.service.IBuyOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

@RestController
@RequestMapping("buyOrder")
@Api(tags = "采购信息控制层")
public class BuyOrderController {
    @Autowired
    private IBuyOrderService buyOrderService;

    @ApiOperation("动态条件分页查询订单")
    @GetMapping("findByItem")
    public IPage<BuyOrderBean> findByItem(Integer pageNO, String supplierName, LocalDate startDate, LocalDate endDate){
        return buyOrderService.findByItem(pageNO,supplierName,startDate,endDate);
    }


    @ApiOperation("根据id查订单")
    @GetMapping("findById")
    public BuyOrderBean findById(Integer OrderId){
        return buyOrderService.findById(OrderId);
    }

    @ApiOperation("添加采购订单")
    @PutMapping("add")
    public Integer add(String supplierName, String realName){
        return buyOrderService.add(supplierName,realName);
    }


}
